#include "N2WorldTransform.h"

N2WorldTransform::N2WorldTransform()
{
    eM22 = eM11 = 1;
    eM12 = eM21 = eDx = eDy = 0;
}

N2WorldTransform::N2WorldTransform(const XFORM &xf) : eM11(xf.eM11), eM12(xf.eM12), 
                                                      eM21(xf.eM21), eM22(xf.eM22),
                                                      eDx(xf.eDx), eDy(xf.eDy)
{
}

XFORM N2WorldTransform::getXFORM() const 
{
    XFORM xf;

    xf.eM11 = eM11; 
    xf.eM12 = eM12;
    xf.eM21 = eM21;
    xf.eM22 = eM22;
    xf.eDx  = eDx;
    xf.eDy  = eDy;

    return xf;
}

void N2WorldTransform::setOffset(FLOAT dx, FLOAT dy)
{
    eDx = dx;
    eDy = dy;
}

void N2WorldTransform::getOffset(FLOAT &dx, FLOAT &dy)
{
    dx = eDx;
    dy = eDy;
}

void N2WorldTransform::modify(N2Coord &x, N2Coord &y) const 
{
    N2Coord nx = N2Coord(x * eM11 + y * eM21 + eDx);
    N2Coord ny = N2Coord(x * eM12 + y * eM22 + eDy);

    x = nx;
    y = ny;
}
